#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const LL mod = 998244353;


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    LL a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    LL res = ((((a % mod) * (b % mod) % mod)* (c % mod) % mod)- (((d % mod) * (e % mod) % mod) * (f % mod) % mod )+ mod) % mod;
    cout << res << '\n';


    return 0;
}